<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 引入easyui的样式 -->
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/default/easyui.css">
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/icon.css">
<!-- js文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function() {
	$('#StuList').datagrid({
		url:"ClassMsg",
		queryParams: {			
			uid:"${user.uid}",
		}
		
	})
})
var ustate=${sessionScope.user.ustate};
var myDate =new Date();
function addmsg() {
	$('#dlg').dialog('open').dialog('center').dialog('setTitle','班级消息添加');
	 $('#fm').form('clear');
	 $('#sd').hide();
	 $(function(){
		 $("#ok").click(function(){
			var newname = $("#newnmsg").val();
			var date =myDate.toLocaleString();			
			$.ajax({
	   				type:"post",
	   				url:"addMsg",
	   				data:{"Msg":newname,"Date":date},
	   				dataType:"text",
	   				success:function(data){
			    		if(data=="true"){
			    			$.messager.alert('提示','添加成功','info',function(){
			    				$('#StuList').datagrid('reload'); 
			    				$('#dlg').dialog('close');
			    			}); 			    							 	    					    			
			    		  }else{
			    			  $.messager.alert('提示','添加失败','info',function(){
				    				$('#StuList').datagrid('reload'); 
			    			  });
			    		  }
			    	}    		   		
	    	})
	 })
 })

}


</script>
<body>
	 <table id="StuList" title="个人信息查询" class="easyui-datagrid" method="post"
            toolbar="#toolbar" pagination="true" fit="true"  
            striped="true"  
            rownumbers="true" fitColumns="true" border="false">         
        <thead>
        <a id="btn" href="#" class="easyui-linkbutton" onclick="addmsg()">添加消息</a>  
        
            <tr>  
                <th field="ck" checkbox="true"></th>               
                <th field="nid" hidden="true">用户编号</th>
                <th field="ntext" width="10" resizable="false">班级消息</th>
                <th field="ndata" width="10" resizable="false">消息时间</th>
                                   
            </tr>
        </thead>
    </table>
    <!-- 个人信息框 -->  
        <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
            closed="true" buttons="#dlg-buttons">
        <div style="margin-left: 60px"> 
        <div class="ftitle" style="margin-left: 80px">用户信息</div><br>   
        <form id="fm" method="post" novalidate>
             <div class="fitem" id="sd">
                <label>用户编号:</label>
                <input id="newnid" class="easyui-textbox" >
            </div>       
            <div class="fitem">
                <label>班级消息:</label>
                <input id="newnmsg" class="easyui-textbox">
            </div>
        </form>
       </div>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok"  style="width:90px;" id="ok" >保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" 
        onclick="javascript:$('#dlg').dialog('close')" style="width:90px;">取消</a>
    </div>
</body>
</html>